package com.example.helloworld;

/**
 * ClassName: RecursionDemo
 * Package: com.example.helloworld
 * Description:
 *
 * @Author guotingting
 * @Create 2025/4/24 9:30 AM
 * @Version 1.0
 */
public class RecursionDemo {
    public static void main(String[] args) {
        RecursionDemo demo = new RecursionDemo();
        int num = 5;
        int sum = demo.getSum(num);
        System.out.println(sum);
    }

    public int getSum(int num) {
        if (num == 1) {
            return 1;
        }

        return num + getSum(num - 1);
    }
}
